<?php
if (!defined('ZAZA')) exit('No direct script access allowed');
/**
 * @copyright     ZaZa Group
 * @author        Sir Doan
 */

class AdminModuleAdd extends Form
{
    function __construct()
    {                          
        Form::__construct('AdminModuleAddForm');
        tpl()->layout = 'admin';  
    } 
    // Method Submit
    function is_submit()
    {
         $pageInfo = array( 'name' => Obj()->get('name'), 
                            'gameid' => Obj()->get('gamed', 'int', 0),
                            'pageid' => Obj()->get('pageid', 'int', 0));
         require_once MODEL_PATH . DS .'AdminModule_model.php';
         $objModule = new AdminModule_Model();
         $res = $objModule->add($pageInfo);
         if($res)
            Url::redirectUrl(Url::buildUrl(null, 'admin_module', true), true);
    } 
    // Method Draw
    function draw()
    {              
        $games = db()->select('game', '*', 'parentid != 0 AND status = 1');
        tpl()->assign('games', $games);
        $pages = db()->select('pages', '*', 'status = 1');
        tpl()->assign('pages', $pages);
        tpl()->assign('form', array('begin' => $this->begin(), 'end' => $this->end()));
        return tpl()->display('admin_module_add'); 
    }
}  
?>
